package com.projrct;

import javax.swing.*;
import java.io.DataOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.Properties;

public class Writer {
    public static void main(String[] args) {
        Properties po = new Properties();
        try {
            po.load(new FileReader("Class8_24/src/user.txt"));
        } catch (Exception e){
            System.out.println("文件不存在");
        }
         //写入文件
        po.setProperty("phone","12345678901");
        po.setProperty("status","在职");
        po.setProperty("workNum","001");
        try {
            po.store(new FileWriter("Class8_24/src/user.txt"),null);
        }catch (Exception e){
            System.out.println("文件不存在");
        }

        System.out.println(po.getProperty("userName"));
        System.out.println(po.getProperty("pwd"));

        po.setProperty("workNum","003");
        try {
            po.store(new FileWriter("Class8_24/src/user.txt"),null);
        }catch (Exception e){
            System.out.println("文件不存在");
        }

        po.setProperty("workNum","002");
        try {
            po.store(new FileWriter("Class8_24/src/user.txt"),null);
        }catch (Exception e){
            System.out.println("文件不存在");
        }

        po.setProperty("workNum","004");
    }
}
